package com.lxg.service.impl;

import com.lxg.dao.UserMapper;
import com.lxg.pojo.User;
import com.lxg.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @author 陆小根
 * date: 2022/04/21
 * Description:
 */
@Service
@Transactional
public class UserServiceImpl implements UserService {

  @Autowired
  private UserMapper userMapper;

  @Override
  @Transactional(propagation = Propagation.SUPPORTS)
  public List<User> findAll() {
    return userMapper.findAll();
  }

  @Override
  public void save(User user) {
    userMapper.save(user);
  }

  @Override
  public void delete(String id) {
    userMapper.delete(id);
  }

  @Override
  public void update(User user) {
   userMapper.update(user);
  }

  @Override
  public List<User> findByPage(Integer pageNow, Integer rows) {
    int start = (pageNow - 1) * rows;
    return userMapper.findByPage(start, rows);
  }

  @Override
  public Long findTotals() {
    return userMapper.findTotals();
  }
}
